import { Effect_tag } from "../../../shared/interface";
import battlefield from "../battle/battlefield";
import { baseBody } from "../body/baseBody";
import { SKILL } from "./SK_active";

class SK_getTag {
    constructor() {

    }
    /**
     * 计算分析出技能目标人群
     * @param SK 
     * @param tag 
     * @param bodys 
     * @returns 
     */
    count(SK: SKILL, tag: Effect_tag, bodys: baseBody[]) {
        let filteredBodys: baseBody[] = []
        switch (tag) {
            case Effect_tag.友军:
                filteredBodys = bodys.filter((body) => {
                    return SK.tool_getGroup() == SK.tool_getTagGroup(body) && !body.is_die()
                });
                break;
            case Effect_tag.敌人:
                filteredBodys = bodys.filter((body) => {
                    return SK.tool_getGroup() != SK.tool_getTagGroup(body) && !body.is_die()
                });
                break;

            case Effect_tag.上一个效果的目标:
                filteredBodys = SK._lastFilteredBodys;

                break;
            case Effect_tag.自己:
                filteredBodys = [SK._parent];
                break;
            case Effect_tag.无差别:
                if(SK._parent.get_battle()){
                    filteredBodys = (SK._parent.get_battle() as battlefield).getBody_all();
                    filteredBodys = filteredBodys.filter((body) => {
                        return !body.is_die()
                    });
                }
                break;
            default:
                break;
        }
        SK._lastFilteredBodys = filteredBodys;
        return filteredBodys
    }
}
export default new SK_getTag();